<!DOCTYPE html><html lang="zh-Hans"><head><meta http-equiv="content-type" content="text/html; charset=utf-8"><meta name="x5-fullscreen" content="true"><meta name="full-screen" content="yes"><meta name="theme-color" content="#317EFB"><meta content="width=device-width,initial-scale=1,maximum-scale=5,user-scalable=0" name="viewport"><meta name="description" content="git安装git –version 配置用户信息1234git config --global user.name &quot;xujianhu&quot;git config --global user.email 951649211@qq.comgit config --list  &#x2F;&#x2F;查看git当前配置   如果有多个配置 先使用当前项目配置  然后是用户层面  然后是系统所有用户层面 gi"><meta property="og:type" content="article"><meta property="og:title" content="git基本使用"><meta property="og:url" content="https://buqingdege.gitee.io/xujianhu/git/git/index.html"><meta property="og:site_name" content="Hexo"><meta property="og:description" content="git安装git –version 配置用户信息1234git config --global user.name &quot;xujianhu&quot;git config --global user.email 951649211@qq.comgit config --list  &#x2F;&#x2F;查看git当前配置   如果有多个配置 先使用当前项目配置  然后是用户层面  然后是系统所有用户层面 gi"><meta property="og:locale"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="og:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><meta property="article:published_time" content="2023-10-08T10:33:49.097Z"><meta property="article:modified_time" content="2023-10-08T10:34:14.911Z"><meta property="article:author" content="buqingdege"><meta property="article:tag" content="git"><meta name="twitter:card" content="summary"><meta name="twitter:image" content="https://buqingdege.gitee.io/xujianhu/img/404.jpg"><title>git基本使用</title><link href="/xujianhu/img/favicon.svg?v=2.1.2" rel="icon" type="image/png" sizes="16x16"><link href="/xujianhu/img/favicon.svg?v=2.1.2" rel="icon" type="image/png" sizes="32x32"><link rel="stylesheet" href="/xujianhu/css/plugins/bootstrap.row.css"><link rel="stylesheet" href="https://unpkg.com/@fancyapps/ui@4.0/dist/fancybox.css"><link rel="stylesheet" href="/xujianhu/css/plugins/font-awesome.min.css"><script>window.ASYNC_CONFIG={hostname:"buqingdege.gitee.io",author:"buqingdege",root:"/xujianhu/",typed_text:["buqingdege"],theme_version:"2.1.2",theme:{switch:!0,default:"style-light"},favicon:{logo:"/img/favicon.svg",icon16:"/img/favicon.svg",icon32:"/img/favicon.svg",appleTouchIcon:null,webmanifest:null,visibilitychange:!1,hidden:"/failure.ico",showText:"(/≧▽≦/)咦！又好了！",hideText:"(●—●)喔哟，崩溃啦！"},i18n:{placeholder:"搜索文章...",empty:"找不到您查询的内容: ${query}",hits:"找到 ${hits} 条结果",hits_time:"找到 ${hits} 条结果（用时 ${time} 毫秒）",author:"本文作者：",copyright_link:"本文链接：",copyright_license_title:"版权声明：",copyright_license_content:"本博客所有文章除特别声明外，均默认采用 undefined 许可协议。",copy_success:"复制成功",copy_failure:"复制失败",open_read_mode:"进入阅读模式",exit_read_mode:"退出阅读模式",notice_outdate_message:"距离上次更新已经 undefined 天了, 文章内容可能已经过时。",just:"刚刚",min:"分钟前",hour:"小时前",day:"天前",month:"个月前"},swup:!1,plugin:{flickr_justified_gallery:"https://unpkg.com/flickr-justified-gallery@latest/dist/fjGallery.min.js"},icons:{sun:"far fa-sun",moon:"far fa-moon",play:"fas fa-play",email:"far fa-envelope",next:"fas fa-arrow-right",calendar:"far fa-calendar-alt",clock:"far fa-clock",user:"far fa-user",back_top:"fas fa-arrow-up",close:"fas fa-times",search:"fas fa-search",reward:"fas fa-hand-holding-usd",user_tag:"fas fa-user-alt",toc_tag:"fas fa-th-list",read:"fas fa-book-reader",arrows:"fas fa-arrows-alt-h",double_arrows:"fas fa-angle-double-down",copy:"fas fa-copy"},icontype:"font",highlight:{plugin:"highlighjs",theme:!0,copy:!0,lang:!1,title:"mac",height_limit:200},toc:{post_title:!1}}</script><script id="async-page-config">window.PAGE_CONFIG={isPost:!0,isHome:!1,postUpdate:"2023-10-08 18:34:14"}</script><link data-swup-theme rel="stylesheet" href="/xujianhu/css/index.css?v=2.1.2" id="trm-switch-style"><script>let defaultMode="auto"!==ASYNC_CONFIG.theme.default?ASYNC_CONFIG.theme.default:window.matchMedia("(prefers-color-scheme: light)").matches?"style-light":"style-dark",catchMode=localStorage.getItem("theme-mode")||defaultMode,type="style-dark"===catchMode?"add":"remove";document.documentElement.classList[type]("dark")</script><meta name="generator" content="Hexo 6.3.0"></head><body><div class="trm-app-frame"><div class="trm-preloader"><div class="trm-holder"><div class="preloader"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div></div></div><div class="trm-mode-swich-animation-frame"><div class="trm-mode-swich-animation"><i class="i-sun"><i class="iconfont far fa-sun"></i></i><div class="trm-horizon"></div><i class="i-moon"><i class="iconfont far fa-moon"></i></i></div></div><div id="trm-dynamic-content" class="trm-swup-animation"><div id="trm-scroll-container" class="trm-scroll-container" style="opacity:0"><header class="trm-top-bar"><div class="container"><div class="trm-left-side"><a href="/xujianhu/" class="trm-logo-frame trm-anima-link"><img alt="logo" src="/xujianhu/img/favicon.svg"><div class="trm-logo-text">不情<span>的歌</span></div></a></div><div class="trm-right-side"><div class="trm-menu"><nav><ul><li class="menu-item-has-children"><a href="/xujianhu/" target="">主页</a></li><li class="menu-item-has-children"><a href="/xujianhu/categories/" target="">分类</a></li><li class="menu-item-has-children"><a href="/xujianhu/archives/" target="">归档</a></li><li class="menu-item-has-children"><a data-no-swup href="/xujianhu/tag/" target="">标签</a></li></ul></nav></div><div class="trm-mode-switcher-place"><div class="trm-mode-switcher"><i class="iconfont far fa-sun"></i> <input class="tgl tgl-light" id="trm-swich" type="checkbox"> <label class="trm-swich" for="trm-swich"></label> <i class="iconfont far fa-moon"></i></div></div><form class="site-search-form"><input type="text" id="local-search-input" class="st-search-input" style="margin-bottom:0"></form><div id="local-search-result" class="local-search-result-cls"></div></div><div class="trm-menu-btn"><span></span></div></div></header><link rel="stylesheet" href="css/search.css"><script src="js/jquery.js"></script><script src="js/search.js"></script><script src="js/search_custom.js"></script><div class="trm-content-start"><div class="trm-banner"><img style="object-position:top;object-fit:cover" alt="banner" class="trm-banner-cover" src="/xujianhu/img/banner.png"><div class="trm-banner-content trm-overlay"><div class="container"><div class="row"><div class="col-lg-4"></div><div class="col-lg-8"><div class="trm-banner-text"><div class="trm-label trm-mb-20">NEWS LETTER</div><h1 class="trm-mb-30 trm-hsmb-font">git基本使用</h1><ul class="trm-breadcrumbs trm-label"><li><a href="/xujianhu/" class="trm-anima-link">Home</a></li><li><span>git</span></li></ul></div><span id="scroll-triger" class="trm-scroll-hint-frame"><div class="trm-scroll-hint"></div><span class="trm-label">Scroll down</span></span></div></div></div></div></div><div class="container"><div class="row"><div class="trm-page-sidebar col-lg-4 hidden-sm"><div class="trm-main-card-frame trm-sidebar"><div class="trm-main-card"><div class="trm-mc-header"><div class="trm-avatar-frame trm-mb-20"><img alt="Avatar" class="trm-avatar" src="/xujianhu/images/logo/avatar.jpg"></div><h5 class="trm-name trm-mb-15">不情的歌</h5><div class="trm-label">I`m <span class="trm-typed-text"></span></div></div><div class="trm-divider trm-mb-40 trm-mt-40"></div><div class="trm-social"><a href="https://github.com" title="github" rel="nofollow" target="_blank"><i class="iconfont fab fa-github"></i> </a><a href="https://gitee.com" title="gitee" rel="nofollow" target="_blank"><i class="iconfont iconfont cg-gitee"></i></a></div><div class="trm-divider trm-mb-40 trm-mt-40"></div><ul class="trm-table trm-mb-20"><li><div class="trm-label">地址:</div><div class="trm-label trm-label-light">火星</div></li><li><div class="trm-label">年龄:</div><div class="trm-label trm-label-light">25</div></li></ul><div class="trm-divider trm-mb-40 trm-mt-40"></div><div class="text-center"><a href="mailto:951649211@qq.com" class="trm-btn">联系我 <i class="iconfont far fa-envelope"></i></a></div></div></div></div><div class="trm-page-content col-lg-8"><div id="trm-content" class="trm-content"><div class="trm-post-info row hidden-sm"><div class="col-sm-4"><div class="trm-card trm-label trm-label-light text-center"><i class="iconfont far fa-calendar-alt trm-icon"></i><br>10/08</div></div><div class="col-sm-4"><div class="trm-card trm-label trm-label-light text-center"><i class="iconfont far fa-clock trm-icon"></i><br>18:33</div></div><div class="col-sm-4"><div id="post-author" class="trm-card trm-label trm-label-light text-center"><i class="iconfont far fa-user trm-icon"></i><br>buqingdege</div></div></div><div class="trm-card"><article id="article-container" class="trm-publication"><h1 id="git"><a href="#git" class="headerlink" title="git"></a>git</h1><h2 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h2><p>git –version</p><h2 id="配置用户信息"><a href="#配置用户信息" class="headerlink" title="配置用户信息"></a>配置用户信息</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">git config --global user.name &quot;xujianhu&quot;</span><br><span class="line">git config --global user.email 951649211@qq.com</span><br><span class="line"></span><br><span class="line">git config --list  //查看git当前配置</span><br></pre></td></tr></table></figure><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221216215432362.png" alt="image-20221216215432362" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>如果有多个配置 先使用当前项目配置 然后是用户层面 然后是系统所有用户层面</p><h2 id="git两组概念"><a href="#git两组概念" class="headerlink" title="git两组概念"></a>git两组概念</h2><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221216215907318.png" alt="image-20221216215907318" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><h3 id="区域"><a href="#区域" class="headerlink" title="区域"></a>区域</h3><p>git本质是一个数据库</p><p>工作区：本地代码目录 沙箱环境 git管理的目录</p><p>暂存区：新增或删除的一系列修改 文件 不会每个文件都存一个版本</p><p>版本库：存版本信息</p><p>工作区–&gt;暂存区–&gt;版本库</p><h3 id="对象"><a href="#对象" class="headerlink" title="对象"></a>对象</h3><h4 id="git对象"><a href="#git对象" class="headerlink" title="git对象"></a>git对象</h4><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221216224414896.png" alt="image-20221216224414896" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>git对象</p><p>树对象</p><p>提交对象</p><h2 id="linux基本命令-git底层"><a href="#linux基本命令-git底层" class="headerlink" title="linux基本命令 git底层"></a>linux基本命令 git底层</h2><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221216221507405.png" alt="image-20221216221507405" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>echo新建一个文件 将输出信息放进文件</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">echo &#x27;damu&#x27; &gt;test.txt</span><br><span class="line"></span><br><span class="line">ll</span><br><span class="line"></span><br><span class="line">find ./</span><br><span class="line"></span><br><span class="line"> find ./ -type f</span><br><span class="line"> </span><br><span class="line"> </span><br><span class="line"> mv test.txt file666.txt</span><br><span class="line"></span><br></pre></td></tr></table></figure><p>vim 里面 按i键进入编辑模式 按yy是复制 p是粘贴 esc退出编辑 ： 输入命令 wq 保存退出 q退出</p><h2 id="git常用命令"><a href="#git常用命令" class="headerlink" title="git常用命令"></a>git常用命令</h2><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217153157894.png" alt="image-20221217153157894" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><h3 id="初始化仓库"><a href="#初始化仓库" class="headerlink" title="初始化仓库"></a>初始化仓库</h3><p>在工作区执行 git init 命令初始化一个版本库</p><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221216220909663.png" alt="image-20221216220909663" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>.git就是一个版本库</p><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221216220953264.png" alt="image-20221216220953264" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221216221012720.png" alt="image-20221216221012720" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><h3 id="添加删除到暂存区"><a href="#添加删除到暂存区" class="headerlink" title="添加删除到暂存区"></a>添加删除到暂存区</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">$ git add file.txt  //添加文件到暂存区</span><br><span class="line"></span><br><span class="line">git rm --cached &lt;file&gt;  //删除暂存区文件</span><br><span class="line"></span><br><span class="line">$git  rm  --cached file.txt</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">  </span><br></pre></td></tr></table></figure><h3 id="提交到本地库"><a href="#提交到本地库" class="headerlink" title="提交到本地库"></a>提交到本地库</h3><p>将暂存区的文件提交到本地库形成历史版本</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git commit -m &quot;日志信息&quot; 文件名</span><br><span class="line"></span><br><span class="line"> </span><br></pre></td></tr></table></figure><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217161650554.png" alt="image-20221217161650554" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217161452353.png" alt="image-20221217161452353" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><h3 id="查看版本信息"><a href="#查看版本信息" class="headerlink" title="查看版本信息"></a>查看版本信息</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">$ git reflog //查看引用日志信息 看到了前7位版本号</span><br><span class="line">//这个head指针指向的就是当前版本</span><br><span class="line"></span><br><span class="line">HEAD&#123;0&#125;</span><br></pre></td></tr></table></figure><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217164522507.png" alt="image-20221217164522507" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>命令：git reflog<br>作用：查看提交版本历史记录<br>执行命令后如图：<br><img src="https://raw.githubusercontent.com/e0528/tuchaung/main/20181114102112910.png" alt="在这里插入图片描述" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>从图中可以看到，执行git reflog 命令后，显示出来了很多行记录。</p><p>每行记录都由版本号（commit id SHA），HEAD值和操作描述三部分组成。版本号在第一列，HEAD值在第二列，操作描述信息在第三列。</p><p>版本号<br>在之前都有提到，标识着每一次提交、合并等操作时的版本，相当于唯一标识<br>HEAD值<br>同样用来标识版本，但是不同于版本号的是，Head值是相对的。<br>当HEAD值为HEAD时，表示为提交的最新版本；HEAD^ 表示为最新版本的上一个版本；HEAD^^表示为最新版本的上上个版本；HEAD~100表示为最新版本的往上第100个版本。<br>HEAD值越小，表示版本越新，越大表示版本生成时间越久。</p><p>在上面图中，我们发现HEAD值的展示形式为HEAD@{0}、HEAD@{1}、HEAD@{2}…同样HEAD值的数字越小，表示版本越新，数字越大表示版本越旧。</p><p>操作描述<br>记录了本次是哪种操作，以及操作时编写的描述信息。</p><p>同时，与git log相同的是，git reflog也提供了控制显示条数的选项：<br>命令：git reflog -n<br>执行命令后如图：</p><p><img src="https://raw.githubusercontent.com/e0528/tuchaung/main/20181114102218113.png" alt="在这里插入图片描述" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>如图所示，这里设置显示条数为3条，执行命令后，显示的条数为指定的条数3条。</p><p><img src="https://raw.githubusercontent.com/e0528/tuchaung/main/20181114102331783.png" alt="在这里插入图片描述" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$git log  //查看详细日志信息 还能看到是谁提交的 版本号也是</span><br><span class="line">看到的完整版本号</span><br></pre></td></tr></table></figure><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217164534441.png" alt="image-20221217164534441" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><h3 id="修改文件"><a href="#修改文件" class="headerlink" title="修改文件"></a>修改文件</h3><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217164829689.png" alt="image-20221217164829689" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>修改了文件还未添加到暂存区</p><h3 id="版本穿梭-回退"><a href="#版本穿梭-回退" class="headerlink" title="版本穿梭 回退"></a>版本穿梭 回退</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">先 git reflog 查看版本信息 找到简略版本号</span><br><span class="line"></span><br><span class="line">后执行 git reset --hard 版本号  //--hard 删除新增文件</span><br></pre></td></tr></table></figure><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217171833529.png" alt="image-20221217171833529" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217172130991.png" alt="image-20221217172130991" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>查看git目录下head文件里 看到当前是在master分支</p><p>git目录下refs heads 文件夹下 明显的 记录了master分支 当前的版本号</p><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217172305617.png" alt="image-20221217172305617" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217174708522.png" alt="image-20221217174708522" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>git reset 命令用于回退版本，可以指定退回某一次提交的版本。</p><p>git reset 命令语法格式如下：</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git reset [--soft | --mixed | --hard] [HEAD]</span><br></pre></td></tr></table></figure><p><strong>–mixed</strong> 为默认，可以不用带该参数，用于重置暂存区的文件与上一次的提交(commit)保持一致，工作区文件内容保持不变。</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git reset  [HEAD] </span><br></pre></td></tr></table></figure><p>实例：</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">$ git reset HEAD^            # 回退所有内容到上一个版本  </span><br><span class="line">$ git reset HEAD^ hello.php  # 回退 hello.php 文件的版本到上一个版本  </span><br><span class="line">$ git  reset  052e           # 回退到指定版本</span><br></pre></td></tr></table></figure><p><strong>–soft</strong> 参数用于回退到某个版本：</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git reset --soft HEAD</span><br></pre></td></tr></table></figure><p>实例：</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">$ git reset --soft HEAD~3   # 回退上上上一个版本 </span><br></pre></td></tr></table></figure><p><strong>–hard</strong> 参数撤销工作区中所有未提交的修改内容，将暂存区与工作区都回到上一次版本，并删除之前的所有信息提交：</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git reset --hard HEAD</span><br></pre></td></tr></table></figure><p>实例：</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">$ git reset --hard HEAD~3  # 回退上上上一个版本  </span><br><span class="line">$ git reset –hard bae128  # 回退到某个版本回退点之前的所有信息。 </span><br><span class="line">$ git reset --hard origin/master    # 将本地的状态回退到和远程的一样 </span><br></pre></td></tr></table></figure><p><strong>注意：</strong>谨慎使用 <strong>–-hard</strong> 参数，它会删除回退点之前的所有信息。</p><p><strong>HEAD 说明：</strong></p><ul><li><p>HEAD 表示当前版本</p></li><li><p>HEAD^ 上一个版本</p></li><li><p>HEAD^^ 上上一个版本</p></li><li><p>HEAD^^^ 上上上一个版本</p></li><li><p>以此类推…</p></li></ul><p>可以使用 ～数字表示</p><ul><li><p>HEAD~0 表示当前版本</p></li><li><p>HEAD~1 上一个版本</p></li><li><p>HEAD^2 上上一个版本</p></li><li><p>HEAD^3 上上上一个版本</p></li><li><p>以此类推…</p></li></ul><h3 id="git-reset-HEAD"><a href="#git-reset-HEAD" class="headerlink" title="git reset HEAD"></a>git reset HEAD</h3><p>git reset HEAD 命令用于取消已缓存的内容。</p><p>我们先改动文件 README 文件，内容如下：</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"># Runoob Git 测试</span><br><span class="line"># 菜鸟教程 </span><br></pre></td></tr></table></figure><p>hello.php 文件修改为：</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">&lt;?php</span><br><span class="line">echo &#x27;菜鸟教程：www.runoob.com&#x27;;</span><br><span class="line">echo &#x27;菜鸟教程：www.runoob.com&#x27;;</span><br><span class="line">echo &#x27;菜鸟教程：www.runoob.com&#x27;;</span><br><span class="line">?&gt;</span><br></pre></td></tr></table></figure><p>现在两个文件修改后，都提交到了缓存区，我们现在要取消其中一个的缓存，操作如下：</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">$ git status -s</span><br><span class="line">    M README</span><br><span class="line">    M hello.php</span><br><span class="line">$ git add .</span><br><span class="line">$ git status -s</span><br><span class="line">M  README</span><br><span class="line">M  hello.php</span><br><span class="line">$ git reset HEAD hello.php </span><br><span class="line">Unstaged changes after reset:</span><br><span class="line">M    hello.php</span><br><span class="line">$ git status -s</span><br><span class="line">M  README</span><br><span class="line">    M hello.php</span><br></pre></td></tr></table></figure><p>现在你执行 git commit，只会将 README 文件的改动提交，而 hello.php 是没有的。</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">$ git commit -m &#x27;修改&#x27;</span><br><span class="line">[master f50cfda] 修改</span><br><span class="line">    1 file changed, 1 insertion(+)</span><br><span class="line">$ git status -s</span><br><span class="line">    M hello.php</span><br></pre></td></tr></table></figure><p>可以看到 hello.php 文件的修改并未提交。</p><p>这时我们可以使用以下命令将 hello.php 的修改提交：</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">$ git commit -am &#x27;修改 hello.php 文件&#x27;</span><br><span class="line">[master 760f74d] 修改 hello.php 文件</span><br><span class="line">    1 file changed, 1 insertion(+)</span><br><span class="line">$ git status</span><br><span class="line">On branch master</span><br><span class="line">nothing to commit, working directory clean</span><br></pre></td></tr></table></figure><p>简而言之，执行 git reset HEAD 以取消之前 git add 添加，但不希望包含在下一提交快照中的缓存。</p><h1 id="git放弃本地修改，强制覆盖本地文件"><a href="#git放弃本地修改，强制覆盖本地文件" class="headerlink" title="git放弃本地修改，强制覆盖本地文件"></a>git放弃本地修改，强制覆盖本地文件</h1><p><img src="https://raw.githubusercontent.com/e0528/tuchaung/main/image-20230507172833912.png" alt="image-20230507172833912" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>在使用Git的过程中，有些时候我们只想要git服务器中的最新版本的项目，对于本地的项目中修改不做任何理会，就需要用到Git pull的强制覆盖，具体代码如下：</p><p>$ git fetch –all</p><p>$ git reset –hard origin&#x2F;master</p><p>$ git pull</p><p>Git pull的强制覆盖本地文件在自动化部署项目中很有作用，比如用SaltStack部署web项目，强制覆盖可以保持与服务器内容一致。</p><p>上面的操作有点复杂，直接用git checkout 就ok了</p><h2 id="git分支操作"><a href="#git分支操作" class="headerlink" title="git分支操作"></a>git分支操作</h2><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217173140661.png" alt="image-20221217173140661" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217173420302.png" alt="image-20221217173420302" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217173458936.png" alt="image-20221217173458936" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><h3 id="查看分支"><a href="#查看分支" class="headerlink" title="查看分支"></a>查看分支</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ git branch -v  //带版本号显示当前分支</span><br><span class="line"></span><br></pre></td></tr></table></figure><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217173759477.png" alt="image-20221217173759477" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git branch //只显示有的分支</span><br></pre></td></tr></table></figure><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217173823909.png" alt="image-20221217173823909" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>查看远端 分支</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git branch -a</span><br></pre></td></tr></table></figure><h3 id="创建分支"><a href="#创建分支" class="headerlink" title="创建分支"></a>创建分支</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git  branch 分支名</span><br><span class="line"></span><br><span class="line">git checkout —b 分支名  创建并切换</span><br></pre></td></tr></table></figure><h3 id="合并分支"><a href="#合并分支" class="headerlink" title="合并分支"></a>合并分支</h3><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git merge 其他分支到当前 </span><br></pre></td></tr></table></figure><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217175140202.png" alt="image-20221217175140202" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>master分支没有改 就没有合并的冲突 直接能够合并</p><h4 id="产生冲突"><a href="#产生冲突" class="headerlink" title="产生冲突"></a>产生冲突</h4><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217175339622.png" alt="image-20221217175339622" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>都改了同一文件同一位置后</p><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217175638045.png" alt="image-20221217175638045" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>报了合并错误 蓝色的分支状态变成了合并中的状态</p><p>查看当前工作区状态 发现</p><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217175821432.png" alt="image-20221217175821432" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>both modified:</p><p>这时候需要手动合并了</p><p>打开有冲突的文件</p><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217180027727.png" alt="image-20221217180027727" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>&#x3D;&#x3D;&#x3D;号上面是master 分支的代码 等号后面是hot-fix的代码 手动删除不需要的代码将&lt;&lt;&lt;&lt;head &gt;&gt;&gt;hotfix 等删除 留下需要的代码</p><p>最后在master分支推送到暂存区 提交一次代码 冲突解决</p><h3 id="删除分支"><a href="#删除分支" class="headerlink" title="删除分支"></a>删除分支</h3><p>在用git开发过程中，我们在分支合并后会将分支删除。这里我们会遇到两种情况，一是本地和远程的分支都还在，另一种就是远程仓库已经删除了，但本地仓库还有备份。</p><p>本地和远程分支都在<br>这是最常见的情况了，在这种情况下，我们会先删除本地分支，再删除远程分支。</p><ol><li><h4 id="删除本地分支"><a href="#删除本地分支" class="headerlink" title="删除本地分支"></a>删除本地分支</h4></li></ol><p>在git中，删除本地分支并不会影响远程仓库中的任何分支。删除本地分支的命令：</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git branch -d &lt;local_branch&gt;</span><br></pre></td></tr></table></figure><p>先列出所有本地分支</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">$ git branch</span><br><span class="line">* feature/test1</span><br><span class="line">  main</span><br><span class="line"></span><br></pre></td></tr></table></figure><p>我们可以看到现在本地有两个分支，当前在&lt;feature&#x2F;test1&gt;这个分支上。接下去我们要删除这个分支，就得先切换到其他分支</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">$ git checkout main</span><br><span class="line">Switched to branch &#x27;main&#x27;</span><br><span class="line">Your branch is up to date with &#x27;origin/main&#x27;.</span><br><span class="line">$ git branch -d feature/test1 </span><br><span class="line">Deleted branch feature/test1.</span><br><span class="line"></span><br></pre></td></tr></table></figure><blockquote><p>​	注意，如果分支包含未合并的更改和未推送的提交，则该 -d标志将不允许删除本地分支。此时，如果你确定了不想要分支的内容，可以使用 -D替换 -d来强制删除此分支</p></blockquote><p>现在我们再来看看分支情况：</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">$ git branch -a</span><br><span class="line">* main</span><br><span class="line">  remotes/origin/HEAD -&gt; origin/main</span><br><span class="line">  remotes/origin/feature/test1</span><br><span class="line">  remotes/origin/main</span><br><span class="line"></span><br></pre></td></tr></table></figure><p>此时我们已经成功删除了本地仓库&lt;feature&#x2F;test1&gt;，但我们之前有推送过分支到远程仓库，从上面列表可知，远程仓库中还存在此分支，那我们还需要删除远程仓库中的分支。</p><ol start="2"><li><h4 id="删除远程分支"><a href="#删除远程分支" class="headerlink" title="删除远程分支"></a>删除远程分支</h4></li></ol><p>删除远程分支的命令：</p><blockquote><p>​	git push<remote_name>-d<remote_branch></remote_branch></remote_name></p></blockquote><p>先列出所有远程分支：</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">$ git branch -r</span><br><span class="line">  origin/HEAD -&gt; origin/main</span><br><span class="line">  origin/feature/test1</span><br><span class="line">  origin/main</span><br><span class="line"></span><br></pre></td></tr></table></figure><p>我们可以看到，此时远程仓库有&lt;origin&#x2F;feature&#x2F;test1&gt;和&lt;origin&#x2F;main&gt;两个分支</p><p>origin&#x2F;HEAD并非分支，它指向远程服务器上的默认分支，即为origin的远程仓库中的HEAD，一般此值的指向不会改变</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">$ git push origin -d feature/test1</span><br><span class="line">To https://github.com/***/git-practice.git</span><br><span class="line"> - [deleted]         feature/test1</span><br><span class="line"></span><br></pre></td></tr></table></figure><p>这时候再看看分支情况</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">$ git branch -a</span><br><span class="line">* main</span><br><span class="line">  remotes/origin/HEAD -&gt; origin/main</span><br><span class="line">  remotes/origin/main</span><br><span class="line"></span><br></pre></td></tr></table></figure><p>可以看到我们已经成功删除了本地和远程仓库中的分支。此时，去Github上查看时，分支也已经删除。</p><p>清理远程仓库已经删除的分支<br>有时候因为操作不当，直接在远程仓库中删除了分支，而本地仓库还保留着原来的远程分支副本。此时再用git push<remote_name>-d<remote_branch>删除分支会提示错误：</remote_branch></remote_name></p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">$ git branch -a</span><br><span class="line">* feature/test2</span><br><span class="line">  main</span><br><span class="line">  remotes/origin/HEAD -&gt; origin/main</span><br><span class="line">  remotes/origin/feature/test2</span><br><span class="line">  remotes/origin/main</span><br><span class="line"></span><br></pre></td></tr></table></figure><p>此时，我们去Github上直接删除&lt;feature&#x2F;test2&gt;这个分支，然后再同前文一样进行分支删除。</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">$ git branch -d feature/test2</span><br><span class="line">Deleted branch feature/test2</span><br><span class="line"></span><br><span class="line">$ git push origin -d feature/test2</span><br><span class="line">error: unable to delete &#x27;feature/test2&#x27;: remote ref does not exist</span><br><span class="line">error: failed to push some refs to &#x27;https://github.com/***/git-practice.git&#x27;</span><br><span class="line"></span><br><span class="line">$ git branch -a</span><br><span class="line">* main</span><br><span class="line">  remotes/origin/HEAD -&gt; origin/main</span><br><span class="line">  remotes/origin/feature/test2</span><br><span class="line">  remotes/origin/main</span><br><span class="line"></span><br></pre></td></tr></table></figure><p>当我们查看分支时，可以看到&lt;remotes&#x2F;origin&#x2F;feature&#x2F;test2&gt;还是存在的。此时，我们以下命令查看远程分支和本地的对应关系：</p><blockquote><p>​	git remote show<remote_name></remote_name></p></blockquote><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">$ git remote show origin</span><br><span class="line">* remote origin</span><br><span class="line">  Fetch URL: https://github.com/***/git-practice.git</span><br><span class="line">  Push  URL: https://github.com/***/git-practice.git</span><br><span class="line">  HEAD branch: main</span><br><span class="line">  Remote branches:</span><br><span class="line">    main                              tracked</span><br><span class="line">    refs/remotes/origin/feature/test2 stale (use &#x27;git remote prune&#x27; to remove)</span><br><span class="line">  Local branch configured for &#x27;git pull&#x27;:</span><br><span class="line">    main merges with remote main</span><br><span class="line">  Local ref configured for &#x27;git push&#x27;:</span><br><span class="line">    main pushes to main (up to date)</span><br><span class="line"></span><br></pre></td></tr></table></figure><p>我们可以看到main分支的状态是tracked，而feature&#x2F;test2的状态是stale，并且后面git已经提示了处理方式(use ‘git remote prune’ to remove)。</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line">$ git remote prune origin</span><br><span class="line">Pruning origin</span><br><span class="line">URL: https://github.com/***/git-practice.git</span><br><span class="line"> * [pruned] origin/feature/test2</span><br><span class="line"></span><br><span class="line">$ git branch -a </span><br><span class="line">* main</span><br><span class="line">  remotes/origin/HEAD -&gt; origin/main</span><br><span class="line">  remotes/origin/main</span><br><span class="line"></span><br></pre></td></tr></table></figure><p>至此我们已经成功清理掉远程已经删除的分支在本地的缓存。</p><h2 id="git团队协作"><a href="#git团队协作" class="headerlink" title="git团队协作"></a>git团队协作</h2><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217193109133.png" alt="image-20221217193109133" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><h3 id="团队内协作"><a href="#团队内协作" class="headerlink" title="团队内协作"></a>团队内协作</h3><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217193800023.png" alt="image-20221217193800023" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><h3 id="跨团队协作"><a href="#跨团队协作" class="headerlink" title="跨团队协作"></a>跨团队协作</h3><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217193818283.png" alt="image-20221217193818283" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><h3 id="创建远程库"><a href="#创建远程库" class="headerlink" title="创建远程库"></a>创建远程库</h3><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217195145515.png" alt="image-20221217195145515" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><h4 id="创建远程库别名-（链接）"><a href="#创建远程库别名-（链接）" class="headerlink" title="创建远程库别名 （链接）"></a>创建远程库别名 （链接）</h4><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217195234871.png" alt="image-20221217195234871" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>起别名的原因是 url链接太长了 推送拉取 不方便 起个别名更方便</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">$ git remote -v 查看当前所有的远程地址别名 </span><br><span class="line"></span><br><span class="line">$ git remote add &lt;别名 一般为项目名&gt;  &lt;远程地址&gt;</span><br></pre></td></tr></table></figure><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217195623926.png" alt="image-20221217195623926" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><blockquote><p>​	修改远程仓库别名</p><p>git remote rename old-name new-name</p></blockquote><h4 id="本地库推送到远程库"><a href="#本地库推送到远程库" class="headerlink" title="本地库推送到远程库"></a>本地库推送到远程库</h4><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217195745616.png" alt="image-20221217195745616" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git push 别名 分支  推送的最小的单位是分支</span><br><span class="line"></span><br><span class="line">$ git push &lt;远程库别名/链接&gt; 分支</span><br></pre></td></tr></table></figure><p>一、git push origin</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git push origin</span><br></pre></td></tr></table></figure><p>上面命令表示，将当前分支推送到origin主机的对应分支。 如果当前分支只有一个追踪分支，那么主机名都可以省略。</p><p>注：origin是远程仓库别名，是通过 配置远程仓库</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">git remote add origin http://xxxx@git.XXXX.com/scm/wbqa/xxxx.git</span><br><span class="line"># origin 为远程仓库别名  后面http 为远程仓库地址</span><br></pre></td></tr></table></figure><p>二、git push</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git push</span><br></pre></td></tr></table></figure><p>如果当前分支与多个主机存在追踪关系，那么这个时候-u选项会指定一个默认主机，这样后面就可以不加任何参数使用git push。</p><p>三、git push -u origin master</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git push -u origin master</span><br></pre></td></tr></table></figure><p>上面命令将本地的master分支推送到origin主机，同时指定origin为默认主机，后面就可以不加任何参数使用git push了。不带任何参数的git push，默认只推送当前分支，这叫做simple方式。此外，还有一种matching方式，会推送所有有对应的远程分支的本地分支。Git 2.0版本之前，默认采用matching方法，现在改为默认采用simple方式。</p><p>四、本地master上传到远程仓库分支下</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">git push &lt;远程主机名&gt; &lt;本地分支名&gt;:&lt;远程分支名&gt;</span><br><span class="line">git push origin master:djs</span><br><span class="line"># origin为设置的远程仓库别名, master为本地分支名, djs为远程分支名</span><br></pre></td></tr></table></figure><h4 id="远程拉取代码"><a href="#远程拉取代码" class="headerlink" title="远程拉取代码"></a>远程拉取代码</h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git pull 远程库别名 分支</span><br></pre></td></tr></table></figure><p>拉取代码会在本地自动提交一次 合并 本地变为新版本</p><h1 id="git-pull-命令"><a href="#git-pull-命令" class="headerlink" title="git pull 命令"></a>git pull 命令</h1><p><a target="_blank" rel="noopener" href="https://m.runoob.com/git/git-basic-operations.html"><img src="https://m.runoob.com/images/up.gif" alt="Git 基本操作" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'>Git 基本操作</a></p><hr><p><strong>git pull</strong> 命令用于从远程获取代码并合并本地的版本。</p><p><strong>git pull</strong> 其实就是 git fetch 和 git merge FETCH_HEAD 的简写。</p><p>命令格式如下：</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git pull &lt;远程主机名&gt; &lt;远程分支名&gt;:&lt;本地分支名&gt;</span><br></pre></td></tr></table></figure><h3 id="实例"><a href="#实例" class="headerlink" title="实例"></a>实例</h3><p>更新操作：</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">$ git pull</span><br><span class="line">$ git pull origin</span><br></pre></td></tr></table></figure><p>将远程主机 origin 的 master 分支拉取过来，与本地的 brantest 分支合并。</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git pull origin master:brantest</span><br></pre></td></tr></table></figure><p>如果远程分支是与当前分支合并，则冒号后面的部分可以省略。</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git pull origin master</span><br></pre></td></tr></table></figure><p>上面命令表示，取回 origin&#x2F;master 分支，再与本地的 brantest 分支合并。</p><p>上面的 pull 操作用 fetch 表示为：</p><p>以我的 <a target="_blank" rel="noopener" href="https://github.com/tianqixin/runoob-git-test">https://github.com/tianqixin/runoob-git-test</a> 为例，远程载入合并本地分支。</p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">$ git remote -v  # 查看信息</span><br><span class="line">origin	https://github.com/tianqixin/runoob-git-test (fetch)</span><br><span class="line">origin	https://github.com/tianqixin/runoob-git-test (push)</span><br><span class="line"></span><br><span class="line">$ git pull origin master</span><br><span class="line">From https://github.com/tianqixin/runoob-git-test</span><br><span class="line"> * branch            master     -&gt; FETCH_HEAD</span><br><span class="line">Already up to date.</span><br></pre></td></tr></table></figure><p>上面命令表示，取回 origin&#x2F;master 分支，再与本地的 master 分支合并。</p><h4 id="克隆远程库"><a href="#克隆远程库" class="headerlink" title="克隆远程库"></a>克隆远程库</h4><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git clone 链接</span><br></pre></td></tr></table></figure><p>克隆是不需要登录的</p><p>1.拉取代码 2 初始化本地仓库 3 自动创建别名 origin</p><h3 id="团队内协作-1"><a href="#团队内协作-1" class="headerlink" title="团队内协作"></a>团队内协作</h3><p>需要将成员添加到项目</p><h3 id="跨团队协作-1"><a href="#跨团队协作-1" class="headerlink" title="跨团队协作"></a>跨团队协作</h3><p>在搜索时拼上用户名更好搜</p><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217205831486.png" alt="image-20221217205831486" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>首先fork一下 到自己账号</p><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217210004829.png" alt="image-20221217210004829" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217210026453.png" alt="image-20221217210026453" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>修改 完成后 返回给项目主审核</p><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217210156795.png" alt="image-20221217210156795" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><h2 id="ssh免密登录"><a href="#ssh免密登录" class="headerlink" title="ssh免密登录"></a>ssh免密登录</h2><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217210856210.png" alt="image-20221217210856210" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>在本地</p><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217210954602.png" alt="image-20221217210954602" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">$ ssh -keygen -t rsa -C 邮箱</span><br><span class="line"> -keygen 生成公钥</span><br><span class="line"> -t 选择协议 </span><br><span class="line"> rsa 公钥私钥协议</span><br><span class="line"> -C 描述</span><br><span class="line"> 针对的邮箱</span><br></pre></td></tr></table></figure><p>连续点击三次回车</p><p>然后发现用户文件夹多了一个.ssh文件夹</p><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217211253434.png" alt="image-20221217211253434" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>生成了公钥和私钥</p><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217211303126.png" alt="image-20221217211303126" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>此时把id_rsa.pub文件内容复制</p><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217211505029.png" alt="image-20221217211505029" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>来到账号设置</p><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217211527479.png" alt="image-20221217211527479" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>添加公钥</p><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217211548106.png" alt="image-20221217211548106" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217211619042.png" alt="image-20221217211619042" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p>title 随便 将公钥内容复制到key</p><p>这时windows链接就不需要密码 了</p><h2 id="码云"><a href="#码云" class="headerlink" title="码云"></a>码云</h2><h3 id="复制迁移github项目"><a href="#复制迁移github项目" class="headerlink" title="复制迁移github项目"></a>复制迁移github项目</h3><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217213135509.png" alt="image-20221217213135509" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217213147943.png" alt="image-20221217213147943" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><h2 id="gitlab"><a href="#gitlab" class="headerlink" title="gitlab"></a>gitlab</h2><p><img src="http://home.weipiaopiao.top:9552/e0528/tuchuang/raw/branch/master/image-20221217213509213.png" alt="image-20221217213509213" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><h2 id="gitignore的使用"><a href="#gitignore的使用" class="headerlink" title="gitignore的使用"></a>gitignore的使用</h2><p><img src="C:/Users/xujianhu/AppData/Roaming/Typora/typora-user-images/image-20230227203242598.png" alt="image-20230227203242598" loading="lazy" onerror='this.onerror=null,this.src="/xujianhu/img/404.jpg"'></p><h1 id="使用clash代理"><a href="#使用clash代理" class="headerlink" title="使用clash代理"></a>使用clash代理</h1><h4 id="1、github-设置网络代理，加速-github"><a href="#1、github-设置网络代理，加速-github" class="headerlink" title="1、github 设置网络代理，加速 github"></a>1、github 设置网络代理，加速 github</h4><ul><li>http 和 https 协议的 git 代理，打开终端，在任意目录下执行如下命令（按需选择一种即可）</li></ul><p>第一种：设置所有 git 操作都走 clash 代理</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">// 添加代理</span><br><span class="line">git config --global http.proxy http://127.0.0.1:7890</span><br><span class="line">git config --global https.proxy https://127.0.0.1:7890</span><br><span class="line"></span><br><span class="line">// 取消代理</span><br><span class="line">git config --global --<span class="built_in">unset</span> http.proxy</span><br><span class="line">git config --global --<span class="built_in">unset</span> https.proxy</span><br></pre></td></tr></table></figure><p>第二种：仅 github.com 走 clash 代理，因为可能有的朋友公司内网的 git 仓库无需走代理</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line">// 添加代理</span><br><span class="line">git config --global http.https://github.com.proxy http://127.0.0.1:7890</span><br><span class="line">git config --global https.https://github.com.proxy https://127.0.0.1:7890</span><br><span class="line"></span><br><span class="line">// 取消代理</span><br><span class="line">git config --global --<span class="built_in">unset</span> http.https://github.com.proxy</span><br><span class="line">git config --global --<span class="built_in">unset</span> https.https://github.com.proxy</span><br></pre></td></tr></table></figure><blockquote><p>可使用 <code>git config -l</code> 命令查看 git 的所有配置信息</p></blockquote></article></div><div class="trm-post-next-prev row"><div class="col-lg-12"><h5 class="trm-title-with-divider">其他文章 <span data-number="02"></span></h5></div><div class="col-lg-6"><div class="trm-blog-card trm-scroll-animation"><a href="/xujianhu/hexo/%E4%B8%BAhexo%E5%88%9B%E5%BB%BA%E6%9C%AC%E5%9C%B0%E6%90%9C%E7%B4%A2%E5%BC%95%E6%93%8E/" class="trm-cover-frame trm-anima-link"><img alt="cover" class="no-fancybox" src="/xujianhu/img/block.jpg"></a><div class="trm-card-descr"><div class="trm-label trm-category trm-mb-20"><a href="/xujianhu/categories/hexo/">hexo</a></div><h5><a href="/xujianhu/hexo/%E4%B8%BAhexo%E5%88%9B%E5%BB%BA%E6%9C%AC%E5%9C%B0%E6%90%9C%E7%B4%A2%E5%BC%95%E6%93%8E/" class="trm-anima-link">为 Hexo 博客创建本地搜索引擎</a></h5><div class="trm-divider trm-mb-20 trm-mt-20"></div><ul class="trm-card-data trm-label"><li>23/10/08</li><li>20:26</li></ul></div></div></div><div class="col-lg-6"><div class="trm-blog-card trm-scroll-animation"><a href="/xujianhu/%E5%89%8D%E7%AB%AF%E5%BC%80%E5%8F%91/ajax/" class="trm-cover-frame trm-anima-link"><img alt="cover" class="no-fancybox" src="/xujianhu/img/block.jpg"></a><div class="trm-card-descr"><div class="trm-label trm-category trm-mb-20"><a href="/xujianhu/categories/%E5%89%8D%E7%AB%AF%E5%BC%80%E5%8F%91/">前端开发</a></div><h5><a href="/xujianhu/%E5%89%8D%E7%AB%AF%E5%BC%80%E5%8F%91/ajax/" class="trm-anima-link">ajax基本使用</a></h5><div class="trm-divider trm-mb-20 trm-mt-20"></div><ul class="trm-card-data trm-label"><li>23/10/08</li><li>18:33</li></ul></div></div></div></div><div class="trm-divider footer-divider"></div><footer class="trm-scroll-animation"><div class="trm-footer-item"><span>© 2023- 2023</span> <span class="footer-separator" data-separator=" · "></span> <span class="trm-accent-color">不情的歌</span></div><div class="trm-footer-item">博客已萌萌哒运行 <span id="since" class="trm-accent-color"></span> 天</div><div class="trm-footer-item">当你累的时候你是在走上坡路</div></footer><script>function show_date_time(){var e=new Date("10/07/2023 15:00:00"),t=(new Date).getTime()-e.getTime(),i=Math.floor(t/864e5);since.innerHTML=i}show_date_time()</script></div></div></div></div></div><div id="post-toc" class="trm-post-toc"><div class="trm-post-toc-header">目录导航</div><div class="trm-post-toc-content"><ol class="trm-toc"><li class="trm-toc-item trm-toc-level-1"><a rel="nofollow" class="trm-toc-link" href="#git"><span class="trm-toc-number">1.</span> <span class="trm-toc-text">git</span></a><ol class="trm-toc-child"><li class="trm-toc-item trm-toc-level-2"><a rel="nofollow" class="trm-toc-link" href="#安装"><span class="trm-toc-number">1.1.</span> <span class="trm-toc-text">安装</span></a></li><li class="trm-toc-item trm-toc-level-2"><a rel="nofollow" class="trm-toc-link" href="#配置用户信息"><span class="trm-toc-number">1.2.</span> <span class="trm-toc-text">配置用户信息</span></a></li><li class="trm-toc-item trm-toc-level-2"><a rel="nofollow" class="trm-toc-link" href="#git两组概念"><span class="trm-toc-number">1.3.</span> <span class="trm-toc-text">git两组概念</span></a><ol class="trm-toc-child"><li class="trm-toc-item trm-toc-level-3"><a rel="nofollow" class="trm-toc-link" href="#区域"><span class="trm-toc-number">1.3.1.</span> <span class="trm-toc-text">区域</span></a></li><li class="trm-toc-item trm-toc-level-3"><a rel="nofollow" class="trm-toc-link" href="#对象"><span class="trm-toc-number">1.3.2.</span> <span class="trm-toc-text">对象</span></a></li></ol></li><li class="trm-toc-item trm-toc-level-2"><a rel="nofollow" class="trm-toc-link" href="#linux基本命令-git底层"><span class="trm-toc-number">1.4.</span> <span class="trm-toc-text">linux基本命令 git底层</span></a></li><li class="trm-toc-item trm-toc-level-2"><a rel="nofollow" class="trm-toc-link" href="#git常用命令"><span class="trm-toc-number">1.5.</span> <span class="trm-toc-text">git常用命令</span></a><ol class="trm-toc-child"><li class="trm-toc-item trm-toc-level-3"><a rel="nofollow" class="trm-toc-link" href="#初始化仓库"><span class="trm-toc-number">1.5.1.</span> <span class="trm-toc-text">初始化仓库</span></a></li><li class="trm-toc-item trm-toc-level-3"><a rel="nofollow" class="trm-toc-link" href="#添加删除到暂存区"><span class="trm-toc-number">1.5.2.</span> <span class="trm-toc-text">添加删除到暂存区</span></a></li><li class="trm-toc-item trm-toc-level-3"><a rel="nofollow" class="trm-toc-link" href="#提交到本地库"><span class="trm-toc-number">1.5.3.</span> <span class="trm-toc-text">提交到本地库</span></a></li><li class="trm-toc-item trm-toc-level-3"><a rel="nofollow" class="trm-toc-link" href="#查看版本信息"><span class="trm-toc-number">1.5.4.</span> <span class="trm-toc-text">查看版本信息</span></a></li><li class="trm-toc-item trm-toc-level-3"><a rel="nofollow" class="trm-toc-link" href="#修改文件"><span class="trm-toc-number">1.5.5.</span> <span class="trm-toc-text">修改文件</span></a></li><li class="trm-toc-item trm-toc-level-3"><a rel="nofollow" class="trm-toc-link" href="#版本穿梭-回退"><span class="trm-toc-number">1.5.6.</span> <span class="trm-toc-text">版本穿梭 回退</span></a></li><li class="trm-toc-item trm-toc-level-3"><a rel="nofollow" class="trm-toc-link" href="#git-reset-HEAD"><span class="trm-toc-number">1.5.7.</span> <span class="trm-toc-text">git reset HEAD</span></a></li></ol></li></ol></li><li class="trm-toc-item trm-toc-level-1"><a rel="nofollow" class="trm-toc-link" href="#git放弃本地修改，强制覆盖本地文件"><span class="trm-toc-number">2.</span> <span class="trm-toc-text">git放弃本地修改，强制覆盖本地文件</span></a><ol class="trm-toc-child"><li class="trm-toc-item trm-toc-level-2"><a rel="nofollow" class="trm-toc-link" href="#git分支操作"><span class="trm-toc-number">2.1.</span> <span class="trm-toc-text">git分支操作</span></a><ol class="trm-toc-child"><li class="trm-toc-item trm-toc-level-3"><a rel="nofollow" class="trm-toc-link" href="#查看分支"><span class="trm-toc-number">2.1.1.</span> <span class="trm-toc-text">查看分支</span></a></li><li class="trm-toc-item trm-toc-level-3"><a rel="nofollow" class="trm-toc-link" href="#创建分支"><span class="trm-toc-number">2.1.2.</span> <span class="trm-toc-text">创建分支</span></a></li><li class="trm-toc-item trm-toc-level-3"><a rel="nofollow" class="trm-toc-link" href="#合并分支"><span class="trm-toc-number">2.1.3.</span> <span class="trm-toc-text">合并分支</span></a></li><li class="trm-toc-item trm-toc-level-3"><a rel="nofollow" class="trm-toc-link" href="#删除分支"><span class="trm-toc-number">2.1.4.</span> <span class="trm-toc-text">删除分支</span></a></li></ol></li><li class="trm-toc-item trm-toc-level-2"><a rel="nofollow" class="trm-toc-link" href="#git团队协作"><span class="trm-toc-number">2.2.</span> <span class="trm-toc-text">git团队协作</span></a><ol class="trm-toc-child"><li class="trm-toc-item trm-toc-level-3"><a rel="nofollow" class="trm-toc-link" href="#团队内协作"><span class="trm-toc-number">2.2.1.</span> <span class="trm-toc-text">团队内协作</span></a></li><li class="trm-toc-item trm-toc-level-3"><a rel="nofollow" class="trm-toc-link" href="#跨团队协作"><span class="trm-toc-number">2.2.2.</span> <span class="trm-toc-text">跨团队协作</span></a></li><li class="trm-toc-item trm-toc-level-3"><a rel="nofollow" class="trm-toc-link" href="#创建远程库"><span class="trm-toc-number">2.2.3.</span> <span class="trm-toc-text">创建远程库</span></a></li></ol></li></ol></li><li class="trm-toc-item trm-toc-level-1"><a rel="nofollow" class="trm-toc-link" href="#git-pull-命令"><span class="trm-toc-number">3.</span> <span class="trm-toc-text">git pull 命令</span></a><ol class="trm-toc-child"><li class="trm-toc-item trm-toc-level-3"><a rel="nofollow" class="trm-toc-link" href="#实例"><span class="trm-toc-number">3.0.1.</span> <span class="trm-toc-text">实例</span></a></li><li class="trm-toc-item trm-toc-level-3"><a rel="nofollow" class="trm-toc-link" href="#团队内协作-1"><span class="trm-toc-number">3.0.2.</span> <span class="trm-toc-text">团队内协作</span></a></li><li class="trm-toc-item trm-toc-level-3"><a rel="nofollow" class="trm-toc-link" href="#跨团队协作-1"><span class="trm-toc-number">3.0.3.</span> <span class="trm-toc-text">跨团队协作</span></a></li></ol></li><li class="trm-toc-item trm-toc-level-2"><a rel="nofollow" class="trm-toc-link" href="#ssh免密登录"><span class="trm-toc-number">3.1.</span> <span class="trm-toc-text">ssh免密登录</span></a></li><li class="trm-toc-item trm-toc-level-2"><a rel="nofollow" class="trm-toc-link" href="#码云"><span class="trm-toc-number">3.2.</span> <span class="trm-toc-text">码云</span></a><ol class="trm-toc-child"><li class="trm-toc-item trm-toc-level-3"><a rel="nofollow" class="trm-toc-link" href="#复制迁移github项目"><span class="trm-toc-number">3.2.1.</span> <span class="trm-toc-text">复制迁移github项目</span></a></li></ol></li><li class="trm-toc-item trm-toc-level-2"><a rel="nofollow" class="trm-toc-link" href="#gitlab"><span class="trm-toc-number">3.3.</span> <span class="trm-toc-text">gitlab</span></a></li><li class="trm-toc-item trm-toc-level-2"><a rel="nofollow" class="trm-toc-link" href="#gitignore的使用"><span class="trm-toc-number">3.4.</span> <span class="trm-toc-text">gitignore的使用</span></a></li></ol><li class="trm-toc-item trm-toc-level-1"><a rel="nofollow" class="trm-toc-link" href="#使用clash代理"><span class="trm-toc-number">4.</span> <span class="trm-toc-text">使用clash代理</span></a></li></div></div><div class="trm-fixed-container"><div class="trm-fixed-btn post-toc-btn" data-title="目录"><i class="iconfont fas fa-th-list"></i></div><div class="trm-fixed-btn" data-title="阅读模式" onclick="asyncFun.switchReadMode()"><i class="iconfont fas fa-book-reader"></i></div><div class="trm-fixed-btn hidden-md" data-title="单栏和双栏切换" onclick="asyncFun.switchSingleColumn()"><i class="iconfont fas fa-arrows-alt-h"></i></div><div id="trm-back-top" class="trm-fixed-btn" data-title="回到顶部"><i class="iconfont fas fa-arrow-up"></i></div></div></div></div></div><script src="https://unpkg.com/@fancyapps/ui@4.0/dist/fancybox.umd.js"></script><script src="/xujianhu/js/plugins/typing.js?v=2.1.2"></script><script id="async-script" src="/xujianhu/js/main.js?v=2.1.2"></script><script src="/xujianhu/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/","tagMode":false});</script></body></html>